/**
 * 初始化系统用户表& #40;成为智能& #41;详情对话框
 */
var UserCwInfoDlg = {
    userCwInfoData : {}
};

/**
 * 清除数据
 */
UserCwInfoDlg.clearData = function() {
    this.userCwInfoData = {};
};

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
UserCwInfoDlg.set = function(key, val) {
    this.userCwInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
};

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
UserCwInfoDlg.get = function(key) {
    return $("#" + key).val();
};

/**
 * 关闭此对话框
 */
UserCwInfoDlg.close = function() {
    parent.layer.close(window.parent.UserCw.layerIndex);
};

/**
 * 收集数据
 */
UserCwInfoDlg.collectData = function() {
    this
    .set('suId')
    .set('srId')
    .set('spId')
    .set('supId')
    .set('soId')
    .set('suLoginName')
    .set('suLoginPwd')
    .set('suSalt')
    .set('suPhone')
    .set('suEmail')
    .set('createTime')
    .set('creareUser')
    .set('suState')
    .set('suSort')
    .set('suImg')
    .set('suIdcardType')
    .set('suIdcardNum')
    .set('suiName')
    .set('suiPy')
    .set('suiPyAll')
    .set('suiPyFirst')
    .set('suiSex')
    .set('suiNation')
    .set('suiBirthday')
    .set('suiRemark');
};

/**
 * 提交添加
 */
UserCwInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/userCw/add", function(data){
        Feng.success("添加成功!");
        window.parent.UserCw.table.refresh();
        UserCwInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.userCwInfoData);
    ajax.start();
};

/**
 * 提交修改
 */
UserCwInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/userCw/update", function(data){
        Feng.success("修改成功!");
        window.parent.UserCw.table.refresh();
        UserCwInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.userCwInfoData);
    ajax.start();
};

$(function() {

});
